import courseTypeOptions from "./courseTypeOptions";

export function addArgument(fn, newArg) {
  if (fn) {
    return function (...args) {
      return fn(...args, newArg);
    };
  }
  return null;
}

export const replacePage = (params) => {
  let obj = {};
  for (let i in params) {
    const value = params[i];
    if (i === "pageNum") {
      i = "page";
    }
    obj[i] = value;
  }
  return obj;
};

export const disableStatusOptions = [
  {
    label: "启用",
    value: true,
  },
  {
    label: "停用",
    value: false,
  },
];

export const genderOptions = [
  {
    label: "男",
    value: 1,
  },
  {
    label: "女",
    value: 0,
  },
];

export const studentStatusOptions = [
  {
    label: "在读",
    value: 1,
  },
  {
    label: "停课",
    value: 2,
  },
  {
    label: "休学",
    value: 3,
  },
];

export const weekDayOptions = [
  {
    label: "周一",
    value: 1,
  },
  {
    label: "周二",
    value: 2,
  },
  {
    label: "周三",
    value: 3,
  },
  {
    label: "周四",
    value: 4,
  },
  {
    label: "周五",
    value: 5,
  },
  {
    label: "周六",
    value: 6,
  },
  {
    label: "周日",
    value: 7,
  },
];

export const filterWeekDayOptions = (val) => {
  return weekDayOptions.find((item) => item.value == val)?.label || "-";
};

export const calcWeekDay = (dateString) => {
  const date = new Date(dateString);
  const dayOfWeek = date.getDay();
  const days = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
  return days[dayOfWeek];
};

export const classStatusOptions = [
  {
    value: 1,
    label: "上课",
  },
  {
    value: 2,
    label: "请假",
  },
  {
    value: 3,
    label: "补课",
  },
];

// 翻译 课程阶段
export const filterCourseTypeOptions = (val) => {
  return courseTypeOptions.find((item) => item.value == val)?.label || "-";
};

// 翻译 课程主题
export const filterTopic = ([first, second]) => {
  console.log("first,second===", first, second, courseTypeOptions);
  let arr = [];
  courseTypeOptions.forEach((item) => {
    if (item.value == first) {
      arr = item.children;
    }
  });
  return arr.find((item) => item.value == second)?.label || "-";
};
